package com.atguigu.day06.HomeWork;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @version 1.0
 * @Author 马冰
 * @Date 2024/11/5 18:17
 * @注释
 */
public class HomeWork1 {
    public static int add(int a, int b) {
        return a + b;
    }

    public static int subtract(int a, int b) {
        return a - b;
    }

    public static int multiply(int a, int b) {
        return a * b;
    }

    public static int divide(int a, int b) {
        return a / b;
    }

    public static int remainder(int a, int b) {
        return a % b;
    }

    /*public static int[] calulate(int a, int b) {
        int[] result = new int[5];
        result[0] = add(a, b);
        result[1] = subtract(a, b);
        result[2] = multiply(a, b);
        result[3] = divide(a, b);
        result[4] = remainder(a, b);
        return result;
    }*/
    public static String calulate(int a, int b){
        int i = add(a, b);
        int j = subtract(a, b);
        int k = multiply(a, b);
        int d = divide(a, b);
        int r = remainder(a, b);
        return "和是: " + i + "\n差是: " + j + "\n乘积是: " + k + "\n商是: " + d + "\n余数是: " + r;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入第一位整数: ");
        int a = sc.nextInt();
        System.out.println("请输入第二位整数: ");
        int b = sc.nextInt();
        System.out.println("请输入您想要进行的计算: \n(如果想要展示所有计算结果请输入'=') ");
        char c = sc.next().charAt(0);
        switch (c){
            case '+':
                System.out.println(add(a, b));
                break;
            case '-':
                System.out.println(subtract(a, b));
                break;
            case '*':
                System.out.println(multiply(a, b));
                break;
            case '/':
                System.out.println(divide(a, b));
                break;
            case '%':
                System.out.println(remainder(a, b));
                break;
            case '=':
                //System.out.println(Arrays.toString(calulate(a, b)));
                System.out.println(calulate(a, b));
                break;
        }
        /*if (c == '+'){
            System.out.println(add(a, b));
        }else if (c == '-'){
            System.out.println(subtract(a, b));
        }else if (c == '*'){
            System.out.println(multiply(a, b));
        }else if (c == '/'){
            System.out.println(divide(a, b));
        }else if (c == '%'){
            System.out.println(remainder(a, b));
        }else if(c == '='){
            System.out.println(calulate(a, b));
        }*/
    }
}
